﻿// Decompiled with JetBrains decompiler
// Type: System.Web.Razor.Tokenizer.CSharpHelpers
// Assembly: System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// MVID: 682513D6-F37E-48AC-9909-F3EE103CFF14
// Assembly location: D:\Project\Idea\无人机外网\uav\客户端工程\排查工具\bin\Release\System.Web.Razor.dll

using System.Globalization;

namespace System.Web.Razor.Tokenizer
{
  /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Provides helper functions for the CSharp tokenizer.</summary>
  public static class CSharpHelpers
  {
    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Determines whether the specified character can be used as an identifier start character.</summary>
    /// <returns>true if the specified character can be used as an identifier start character; otherwise, false.</returns>
    /// <param name="character">The character to check.</param>
    public static bool IsIdentifierStart(char character) => char.IsLetter(character) || character == '_' || char.GetUnicodeCategory(character) == UnicodeCategory.LetterNumber;

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Determines whether the specified character can be used for identifier.</summary>
    /// <returns>true if the specified character can be used for identifier; otherwise, false.</returns>
    /// <param name="character">The character to check.</param>
    public static bool IsIdentifierPart(char character) => char.IsDigit(character) || CSharpHelpers.IsIdentifierStart(character) || CSharpHelpers.IsIdentifierPartByUnicodeCategory(character);

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Determines whether the specified character is a literal suffix for real numbers.</summary>
    /// <returns>true if the specified character is a literal suffix for real numbers; otherwise, false.</returns>
    /// <param name="character">The character to check.</param>
    public static bool IsRealLiteralSuffix(char character) => character == 'F' || character == 'f' || (character == 'D' || character == 'd') || character == 'M' || character == 'm';

    private static bool IsIdentifierPartByUnicodeCategory(char character)
    {
      UnicodeCategory unicodeCategory = char.GetUnicodeCategory(character);
      switch (unicodeCategory)
      {
        case UnicodeCategory.NonSpacingMark:
        case UnicodeCategory.SpacingCombiningMark:
        case UnicodeCategory.ConnectorPunctuation:
          return true;
        default:
          return unicodeCategory == UnicodeCategory.Format;
      }
    }
  }
}
